

            function addArduinoCod (Blockly) {
            
                        
                        
                        

                        
        Blockly.Arduino['EXT_ROTARY_ENCODER_BLOCK_1607506903997'] = function(block)
        {
            let pin_a = this.getFieldValue('pin_a');
let pin_b = this.getFieldValue('pin_b');
let pin_d = this.getFieldValue('pin_d');
          
            Blockly.Arduino.definitions_['include_EXT_ROTARY_ENCODER_BLOCK_1607506903997'] = ``;
            Blockly.Arduino.definitions_['define_EXT_ROTARY_ENCODER_BLOCK_1607506903997'] = `#define ENCODER_A_PIN${pin_a} ${pin_a}\r\n#define ENCODER_B_PIN${pin_b} ${pin_b}\r\n#define SWITCH_PIN${pin_d} ${pin_d}\r\nlong position, oldposition;\r\n\r\nvoid read_quadrature(){\r\n  if (digitalRead(ENCODER_A_PIN${pin_a}) == LOW){\r\n    if (digitalRead(ENCODER_B_PIN${pin_b}) == LOW)\r\n      position++;\r\n  }\r\n  else {\r\n    if (digitalRead(ENCODER_B_PIN${pin_b}) == LOW)\r\n      position--;\r\n  }\r\n  oldposition = position;\r\n}`;
            Blockly.Arduino.definitions_['setup_EXT_ROTARY_ENCODER_BLOCK_1607506903997'] = `pinMode(ENCODER_A_PIN${pin_a}, INPUT);\r\n  pinMode(ENCODER_B_PIN${pin_b}, INPUT);\r\n  pinMode(SWITCH_PIN${pin_d}, INPUT);`;
             return  `\r\n`;
        }
                    

                        
        Blockly.Arduino['EXT_ROTARY_ENCODER_BLOCK_1607506904128'] = function(block)
        {
            
          
            Blockly.Arduino.definitions_['include_EXT_ROTARY_ENCODER_BLOCK_1607506904128'] = ``;
            Blockly.Arduino.definitions_['define_EXT_ROTARY_ENCODER_BLOCK_1607506904128'] = ``;
            Blockly.Arduino.definitions_['setup_EXT_ROTARY_ENCODER_BLOCK_1607506904128'] = `attachInterrupt(1, read_quadrature, CHANGE);`;
             return  [`position`];
        }
                    

                        
        Blockly.Arduino['EXT_ROTARY_ENCODER_BLOCK_1607506904234'] = function(block)
        {
            
          
            Blockly.Arduino.definitions_['include_EXT_ROTARY_ENCODER_BLOCK_1607506904234'] = ``;
            Blockly.Arduino.definitions_['define_EXT_ROTARY_ENCODER_BLOCK_1607506904234'] = ``;
            Blockly.Arduino.definitions_['setup_EXT_ROTARY_ENCODER_BLOCK_1607506904234'] = ``;
             return  [`digitalRead(SWITCH_PIN/*{pin_d}*/) == LOW`];
        }
                    
            return Blockly;
            }

            module.exports = addArduinoCod ;

        